package Testing;

import DeportManage.ErrorFormatNameException;
import DeportManage.Name;
import static org.junit.Assert.*;

import org.junit.*;

public class NameTest {
	/**
	 * Test method to instance Name Class to throw exception (ErrorFormatNameException)
	 * there will be 1 or 2 spaces in the name
	 * @throws ErrorFormatNameException 
	 */
	@Test(expected = ErrorFormatNameException.class)
	public void testNameException() throws ErrorFormatNameException{		
		//name is "Yanchao Yu", the format is right
		Name name1 = new Name("Yanchao Yu");
		//name is "Yan chao Yu", the format is right
		Name name2 = new Name("Yan chao Yu");
		//name is "Yanchao Yu". The format is wrong, because there is one space at the end of name.
		Name name3 = new Name("Yan chao Yu ");
		//name is "Yanchao Yu". The format is wrong, because there is one space in the beginning of name.
		Name name4 = new Name(" Yanchao Yu");
		//name is "Yanchao Yu". The format is wrong, because there are three spaces
		Name name5 = new Name("Y anc hao Yu");
		//name is "YanchaoYu". The format is wrong, because there is not space.
		Name name6 = new Name("YanchaoYu");
	}	
	/**
	 * Test method to dispaly the full name
	 * the fomart of full name is "first-name middle-name last-name";
	 * @throws ErrorFormatNameException 
	 */
	@Test
	public void testGetFullName() throws ErrorFormatNameException{
		String expected_a = "Yanchao Yu";
		String message_a = "Failed for full name 'Yanchao Yu'";
		Name name_a = new Name("Yanchao Yu");		
		String actuall_a = name_a.getFullName();
		assertEquals(message_a, expected_a, actuall_a);				

		String expected_b = "Yan Chao Yu";
		String message_b = "Failed for full name 'Yan Chao Yu'";
		Name name_b = new Name("Yan Chao Yu");		
		String actuall_b = name_b.getFullName();
		assertEquals(message_b, expected_b, actuall_b);		
	}
}
